package code.part02_objectOriented;

/**
 * @author: ZJT
 * @Time: 2021/7/10
 * @Description: 内部类
 */
public class P08_InnerClass {

    private int id;
    private String name;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void show(){
        System.out.println("show");
        InnerClass inner = new InnerClass();
        System.out.println(inner.age);
    }

    class InnerClass{
        private int age;
//        static String name;//Inner classes cannot have static declarations

        public void run(){
            System.out.println("run");
            System.out.println(id);
            System.out.println(name);
        }

        class InnerInner{
            private int id;
            public void print(){
                System.out.println("print");
            }
        }
    }

    public static void main(String[] args) {
        P08_InnerClass innerClass = new P08_InnerClass();
        innerClass.show();
        System.out.println(innerClass.getName());

        P08_InnerClass.InnerClass inner = new P08_InnerClass().new InnerClass();
        inner.run();
//        System.out.println(inner.age);

        P08_InnerClass.InnerClass.InnerInner innerInner = new P08_InnerClass().new InnerClass().new InnerInner();
    }
}


